<!DOCTYPE html>
<html>

	<head>
		<script src="jss/global.js" type="text/javascript" charset="utf-8"></script>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>后台权限管理系统</title>
		<link rel="stylesheet" href="css/login.css">
		

	</head>

	<body class="login-bg">
		<canvas id="fullstarbg">你的浏览器不支持canvas标签</canvas>
		<div class="login">
			<div class="message">权限管理系统登录</div>
			<div id="darkbannerwrap"></div>

			<form method="post" id="fmLogin" class="layui-form" onsubmit="return false;">
				
				<input name="loginName" placeholder="用户名" id="un" type="text" lay-verify="required" class="layui-input">
				<hr class="hr15">
				<input name="loginPwd" lay-verify="required" placeholder="密码" type="password" class="layui-input">
				<hr class="hr15">
				<input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
				<hr class="hr20">
			</form>

		</div>
		<script type="text/javascript">
			layui.use(['form',"layer"], function() {
				var $ = layui.jquery;
				var form = layui.form;
				var layer = layui.layer;

				
				//监听提交
				form.on('submit(login)',
					function(data) {
						$.post(globalData.server + "login",
							$("#fmLogin").serialize(),
							function(res) {								
								if(res.code == 0) {
									layer.msg(res.msg, {
										icon: 1,
										time: 1000
									}, function() {										
										globalData.setLoginUid(res.data.uid);
										globalData.setLoginUname(res.data.uname);
										globalData.setLoginUimg(res.data.uimg);
										globalData.setToken(res.data.token);

										//转向首页
										window.location.href = "index.html";
									});

								} else {
									layer.msg(res.msg, {
										icon: 5,
										time: 1000
									});
								}
							}, "json");
						return false;
					}
				);
			});
		</script>

	</body>

</html>